package com.study.结构型模式.适配器模式.对象适配器;

//适配器
public class VoltageAdapter implements IVoltage5V {

    private Voltage220V voltage220V;

    VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    @Override
    public int outPut5V() {

        int destV = 0;
        if (null != voltage220V){
            int srcV = voltage220V.outPut220V();
            System.out.println("使用对象适配器，进行转化");
            destV = srcV / 44;  //转成5V
            System.out.println("适配完成，输出的电压为="+destV+"伏");
        }
        return destV;
    }
}
